//////////////////////////////////////////////////////////////////////////
//
// This file is a part of UKROP project.
// Copyright (c) Vladimir Gumenuk, 2008-2014.
//
// PROJECT:         Xort compiler
// FILE:            WinFile.h - native object support (example)
// AUTHOR:          Vladimir Gumenuk
// DATE:            3-Sep-2014
//
//////////////////////////////////////////////////////////////////////////


#pragma once

// this is just an example how to pass XORT structures to native objects
#pragma pack(1)
struct Vector3D
{
    float x;
    float y;
    float z;
};
#pragma pack()

class CWinFile : public XortNativeInterface
{
public:
    CWinFile();
    virtual ~CWinFile();

// xunknown
IMPLEMENT_XORT_UNKNOWN(WinFile)

    // XortNativeInterface
    // Invokes the object method by name
    virtual int Invoke( lpcstr lpszName, XNIVariantArray *pArgs, XNIVariant& vResultOut );
    
    int     Open( LPCSTR csName, LPCSTR csMode );
    int     Close();
    DWORD   Length();
    LPCSTR  Name();
    int     isOpened();
    DWORD   Read( LPBYTE buf, DWORD dwCount );
    DWORD   Write( const LPBYTE buf, DWORD dwCount );
    int     SaveVector3D( Vector3D *lpVec );

private:
    dword    m_dwRefCount;
    FILE    *m_hFile;
    string   m_strFileName;

};

